// pages/song-list/index.js
import {getPlaylist,getHighQualityList} from "../../service/api_music"
Page({
  data: {
    msg:"",       // 判断热门/推荐 
    // dataInfo:{}   // 数据内容
    popularSongList:[],   // 热门歌单
    recommendSongList:[],  // 推荐歌单
  },
  onLoad(options) {
    console.log(options.msg);
    if(options.msg === "popularSongList"){
      // 热门歌单数据
      this.getPopularSongList()
    }else if(options.msg === "recommendSongList"){
      // 推荐歌单数据
      this.getRecommendSongList()
    }
  },
  // 发送网络请求 热门歌单数据
  async getPopularSongList(){
    let popularSongList = []
    const needTag = ["华语","粤语","欧美","民谣","说唱","轻音乐"]
     for (let i = 0; i < needTag.length; i++) {
      const res = await getPlaylist(needTag[i])
      popularSongList.push(res.data)
    }
    this.setData({popularSongList})
  },
  // 发送网络请求 推荐歌单数据
  async getRecommendSongList(){
    const res =  await getHighQualityList("全部",50)
    this.setData({recommendSongList:res.data})
  },
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})